<?php
/*
Description: This file is used to change login paassword.
*/
#########IncludeFiles####################################################################################
include_once '../inc/config.php';
include_once("../inc/bootstrape.php");
require_once _SITE_PATH_.'classes/CommonUtility/CommonUtility.php';

//	END CHANGE PASSWORD CODE	//
$errMsg = $_GET['err'];
$action = trim($_REQUEST['action']);
$id = trim($_REQUEST['id']); 
if(empty($id)){
    header("Location: "._SITE_ADMIN_URL_."gifts/gift_mng.php");
    exit;
}
$result = CommonUtility::getDataById($id, 'gifts');    
if(isset($_POST['submit'])){
    
    $parms['description'] = $_POST['description'];
    $parms['name'] = $_POST['name'];
    $parms['reward_point'] = $_POST['reward_point'];
        
     // upload and create thumb of the image //
    if( !empty( $_FILES['image'] ) ){
        $filename  = 'image';     //  this is name of the control you are using in html form         
        $module='gifts';
        $uploadedfile = CommonUtility::uploadNcreateThumb($filename, $module, true, 100);
        if( $uploadedfile!= -1 )    {
            $parms['image'] = $uploadedfile;//$_POST['package_image'];
        }
        CommonUtility::removeImage($result['image'], $module); 
    }
    
    $condition = array(); 
    $condition['id'] = $id;
    if( CommonUtility::updateData($parms, 'gifts', $condition)) {        
        header("Location: gift_mng.php?msg=1156");            
        exit;
    }
    $errMsg = 1157;    
}
if( $errMsg ){
    $result = $_POST;
}
$_tplName = 'gifts/gift_edit.tpl';
$_title = 'Edit Gift';
require_once _ADMIN_TPL_MAIN_;
?>